Encoding:

POOL32A

000000

rt

rs

rd

SUBQ.PH

01000001101

POOL32A

000000

rt

rs

rd

SUBQ_S.PH

11000001101

6

5

5

5

11

SPECIAL3

011111

rs

rt

rd

SUBQ.PH

01011

ADDU.QB

010000

SPECIAL3

011111

rs

rt

rd

SUBQ_S.PH

01111

ADDU.QB

010000

6

5

5

5

5

6

Format:

SUBQ[_S].PH 

Subtract Fractional Halfword Vector

SUBQ.PH   rd, rs, rt

microMIPSDSP

Subtract Fractional Halfword Vector

SUBQ_S.PH rd, rs, rt

microMIPSDSP

Subtract Fractional Halfword Vector

Purpose:

Subtract Fractional Halfword Vector

Element-wise subtraction of one vector of Q15 fractional halfword values from another to produce a vector of Q15 fractional halfword results, with optional saturation.

Description:

rd = sign_extend(sat16(rs31..16 - rt31..16)) || sat16(rs15..0 - rt15..0)

The two right-most fractional halfwords in register rt are subtracted from the corresponding fractional halfword elements in register rs.

For the non-saturating version of this instruction, each result is written to the corresponding element in register rd. In the case of overflow or underflow, the result modulo 2 is written to register rd.

For the saturating version of the instruction, the subtraction is performed using signed saturating arithmetic. If the operation results in an overflo w or an un derflow, the result is clamped to either th e largest representable value

(0x7FFF hexadecimal) or the smallest representable value (0x8000 hexadecimal), respectively, before being written to the destination register rd.

For both instructions, the left-most result is sign-extended into the 32 most-significant bits of the destination register.

For both instructions, if any of the individual subtractions result in underflow, overflow, or saturation, a 1 is written to bit 20 in the DSPControl register within the ouflag field.

Restrictions:

No data-dependent exceptions are possible.

The operands must be values in the specified format. If they are not, the results are UNPREDICTABLE and the values of the operand vectors become UNPREDICTABLE.

Operation:

SUBQ.PH:
   tempB15..0 = subtract16( GPR[rs]31..16 , GPR[rt]31..16 )
   tempA15..0 = subtract16( GPR[rs]15..0 , GPR[rt]15..0 )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
SUBQ_S.PH:
   tempB15..0 = sat16Subtract( GPR[rs]31..16 , GPR[rt]31..16 )
   tempA15..0 = sat16Subtract( GPR[rs]15..0 , GPR[rt]15..0 )
   GPR[rd]63..0 = (tempB15)32 || tempB15..0 || tempA15..0
function subtract16( a15..0, b15..0 ) 
   temp16..0 = ( a15 || a15..0 ) - ( b15 || b15..0 )
   if ( temp16 != temp15 ) then
      DSPControlouflag:20 = 1
   endif
   return temp15..0
endfunction subtract16
function sat16Subtract( a15..0, b15..0 )
   temp16..0 = ( a15 || a15..0 ) - ( b15|| b15..0 )
   if ( temp16 != temp15 ) then
      if ( temp16 = 0 ) then
          temp = 0x7FFF
      else
          temp = 0x8000
      endif
      DSPControlouflag:20 = 1
   endif
   return temp15..0
endfunction sat16Subtract

Exceptions:

Reserved Instruction, DSP Disabled